package com.example.meeting.mapper;

import com.example.meeting.model.domain.Meeting;
import com.example.meeting.model.domain.MeetingQuery;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface MeetingMapper {
    //查询会议
    Meeting selectMeetingById(Long id);

    //根据议题id查询会议
    Meeting selectMeetingBySubjectId(Long sid);

    //动态查询会议列表
    List<Meeting> selectMeetingList(@Param("query") MeetingQuery query);
    //List<Meeting> selectMeetingList(@Param("meetingId") Integer[] meetingId, Meeting meeting);

    //新增会议
    @Insert("INSERT INTO meeting(name,position,start_time,end_time,status) " +
            " VALUES(#{name},#{position},#{startTime},#{endTime},#{status})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    Integer addMeeting(Meeting meeting);
    //指定将自增 ID 赋值给实体类的哪个属性。
    //keyColumn = "id"：指定数据库中自增 ID 的列名（通常与主键列名一致）。

    //更新会议
    Integer updateMeeting(Meeting meting);

    //删除会议
    @Delete("DELETE FROM meeting WHERE id=#{id}")
    Integer deleteMeeting(Long id);

    //查询会议状态
    @Select("SELECT status FROM meeting WHERE id=#{id}")
    Integer selectStatusById(Long id);

}
